<?php
namespace Ucenter\Controller;
use User\Api\UserApi;

class ConfigController extends \Common\Controller\UserController{

	public function index(){
		$this->display();
	}

	public function avatar(){
		$this->display();
	}

	/**
     * 修改密码提交
     * @author huajie <banhuajie@163.com>
     */
	public function changepwd(){
        if ( IS_POST ) {
            //获取参数
            $uid        =   is_login();
            $password   =   I('post.old');
            $repassword = I('post.repassword');
            $data['password'] = I('post.password');
            empty($password) && $this->error('请输入原密码');
            empty($data['password']) && $this->error('请输入新密码');
            empty($repassword) && $this->error('请输入确认密码');

            if($data['password'] !== $repassword){
                $this->error('您输入的新密码与确认密码不一致');
            }

            $Api = new UserApi();
            $res = $Api->updateInfo($uid, $password, $data);
            if($res['status']){
                $this->success('修改密码成功！');
            }else{
                $this->error($res['info']);
            }
        }else{
            $this->display();
        }
	}

}